package com.yuncheng.oaApi.FlowController;


import com.baomidou.mybatisplus.core.metadata.IPage;


import com.yuncheng.oaApi.vo.NkRsBmysxmsbVo;
import com.yuncheng.oaApi.vo.OaFlowVo;
import com.yuncheng.oaApi.vo.OaReturnVo;
import com.yuncheng.oaApi.vo.Result;
import com.yuncheng.spcyApi.service.ISpcyLogService;
import com.yuncheng.utils.I18nUtil;
import org.apache.commons.collections.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuncheng.oaApi.FlowService.NewNkbmyssbFlowService;
import com.yuncheng.annotation.AutoLog;
import com.yuncheng.oaApi.busService.MyLcFlowService;
import com.yuncheng.oaApi.constant.OaCommonFlowConstant;
import com.yuncheng.oaApi.constant.OaFlowConstant;
import com.yuncheng.oaApi.entity.*;
import com.yuncheng.exception.BusinessException;
import com.yuncheng.oaApi.mapper.NkRsBmysxmsbFlowMapper;
import com.yuncheng.oaApi.service.*;
import com.yuncheng.spcyApi.utils.DateConvert;
import com.yuncheng.oaApi.utils.GetUuIdUtils;
import com.yuncheng.utils.ThreadContextHelper;
import com.yuncheng.vo.*;
import groovy.lang.Lazy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.C;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import utils.DateConversionUtils;
import utils.LogUtils;
import utils.ObjectToMapUtils;

import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Api(tags = "NEW_预算部门申报")
@RestController
@RequestMapping("/api/spzx-oa/bmyssb")
public class NewNkbmyssbFlowController {

    private static final Logger log = LoggerFactory.getLogger(NewNkbmyssbFlowController.class);

    @Resource
    private IOaSpcySqsxJobService oaSpcySqsxJobService;

    @Resource
    @Lazy
    private IOaSysTzMessageService oaSysTzMessageService;

    @Resource
    @Lazy
    private MyLcFlowService myLcFlowService;

    @Resource
    @Lazy
    private ISpcyLogService spcyLogService;

    @Resource
    @Lazy
    private IOaProcessBusinessService oaProcessBusinessService;

    @Resource
    @Lazy
    private NkRsBmysxmsbFlowMapper nkRsBmysxmsbFlowMapper;

    @Resource
    @Lazy
    private NewNkbmyssbFlowService newNkbmyssbFlowService;

    @Resource
    @Lazy
    private INkRsBmysxmsbService nkRsBmysxmsbService;

    @Resource
    @Lazy
    private INkBmysxmsbXmnrService nkbxmsbXmnrService;

    @Resource
    @Lazy
    private INkBmysxmsbXmyjService nkRsBmysxmsbXmyjService;

    @Resource
    @Lazy
    private INkYssbjxbService nkYssbjxbService;

    @Resource
    @Lazy
    private INkYssbjxbjxzbService nkYssbjxbjxzbService;

    @Resource
    @Lazy
    private INkBmysxmsbsplcService nkBmysxmsbsplcService;

    @Resource
    @Lazy
    private INkRsNdService nkRsNdService;






    /**
     * 流程列表分页查询
     * @param
     * @param pageNo
     * @param pageSize
     * @param onlyCurrentUser
     * @return
     */
    @AutoLog(value = "流程监控-分页查询")
    @ApiOperation(value = "流程监控-分页查询")
    @GetMapping("flowJkPage")
    public HttpResult flowJkPage(
            NkRsBmysxmsbVo nkRsBmysxmsbVo,
            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
            @RequestParam(name = "onlyCurrentUser", defaultValue = "false") boolean onlyCurrentUser) {
        CurrentUserVo user = ThreadContextHelper.getCurrentUser();
        if (user == null) {
            return HttpResult.error("请重新登录，Token已失效！");
        }
        nkRsBmysxmsbVo.setFlcmc(OaFlowConstant.NK_BM_YSSBLC_NAME);
        Page<NkRsBmysxmsbVo> page = new Page<>(pageNo, pageSize);

        IPage<NkRsBmysxmsbVo> list = null;
        if (StringUtils.isNotBlank(nkRsBmysxmsbVo.getOaid())){
            NkRsBmysxmsb xzswsp = nkRsBmysxmsbService.getById(nkRsBmysxmsbVo.getOaid());
            if (xzswsp != null){
                list = nkRsBmysxmsbFlowMapper.flowJkPage(page,onlyCurrentUser,user,nkRsBmysxmsbVo);
            }
        }
        return HttpResult.ok(list);
    }

    /**
     * 流程列表分页查询
     * @param
     * @param pageNo
     * @param pageSize
     * @param onlyCurrentUser
     * @return
     */
    @AutoLog(value = "流程列表-分页查询")
    @ApiOperation(value = "流程列表-分页查询")
    @GetMapping("flowJobPage")
    public HttpResult<?> flowJobPage(
            NkRsBmysxmsbVo nkRsBmysxmsbVo,
            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
            @RequestParam(name = "onlyCurrentUser", defaultValue = "true") boolean onlyCurrentUser) {
        CurrentUserVo user = ThreadContextHelper.getCurrentUser();
        if (user == null) {
            return HttpResult.error("请重新登录，Token已失效！");
        }
        nkRsBmysxmsbVo.setFlcmc(OaFlowConstant.NK_BM_YSSBLC_NAME);
        if (StringUtils.isBlank(nkRsBmysxmsbVo.getFblzt())) {
            nkRsBmysxmsbVo.setFblzt(OaCommonFlowConstant.BLZT_DB);
        }
        Page<NkRsBmysxmsbVo> page = new Page<>(pageNo, pageSize);
        IPage<NkRsBmysxmsbVo> list = nkRsBmysxmsbFlowMapper.flowJobPage(page, onlyCurrentUser, user, nkRsBmysxmsbVo);
        return HttpResult.ok(list);
    }


    /**
     * 我的已办
     */
    @AutoLog(value = "流程列表-我的已办")
    @ApiOperation(value = "流程列表-我的已办")
    @GetMapping("myJobPage")
    public HttpResult<?> myJobPage(
            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
            NkRsBmysxmsbVo nkRsBmysxmsbVo) {
        CurrentUserVo user = ThreadContextHelper.getCurrentUser();
        if (user == null) {
            return HttpResult.error("请重新登录，Token已失效！");
        }
        Page<NkRsBmysxmsbVo> page = new Page<>(pageNo, pageSize);
        IPage<NkRsBmysxmsbVo> list = nkRsBmysxmsbFlowMapper.myYbFlowPage(page, true, user, nkRsBmysxmsbVo);
        return HttpResult.ok(list);
    }


    /**
     * 数据修订
     */
    @AutoLog(value = "列表-数据修订")
    @ApiOperation(value = "列表-数据修订")
    @GetMapping("Pagesjxd")
    public HttpResult<?> Pagesjxd(
            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
            NkRsBmysxmsbVo nkRsBmysxmsbVo) {

        CurrentUserVo user = ThreadContextHelper.getCurrentUser();
        if (user == null) {
            return HttpResult.error("请重新登录，Token已失效！");
        }

        Page<NkRsBmysxmsbVo> page = new Page<>(pageNo, pageSize);
        IPage<NkRsBmysxmsbVo> list = nkRsBmysxmsbFlowMapper.myYbFlowPage(page, false, user, nkRsBmysxmsbVo);
        return HttpResult.ok(list);
    }






    @AutoLog(value = "发起部门预算申报流程")
    @ApiOperation(value = "发起部门预算申报流程")
    @PostMapping(value = "initBzFlow")
    public HttpResult<?> initBzFlow(@RequestBody NkRsBmysxmsb nkRsBmysxmsb) {

        String oaid = "";
        //当前人的id
        CurrentUserVo currentUser = ThreadContextHelper.getCurrentUser();
        if (currentUser == null) {
            return HttpResult.error("当前登录已失效，请重新登录");
        }
        if (StringUtils.isNotBlank(nkRsBmysxmsb.getId())){
            NkRsBmysxmsb nkids = nkRsBmysxmsbService.getById(nkRsBmysxmsb.getId());

            ConvertUtils.register(new DateConvert(), Date.class);
            try {
                BeanUtils.populate(nkids, BeanUtils.describe(nkRsBmysxmsb));
            } catch (IllegalAccessException e) {
                log.error("出错-保存事项【非法访问异常】,{}", e.getMessage());
            } catch (InvocationTargetException e) {
                log.error("出错-保存事项【调用TargetException】,{}", e.getMessage());
            } catch (NoSuchMethodException e) {
                log.error("出错-找不到可用方法", e.getMessage());
            }
            oaid = nkRsBmysxmsb.getId();

            // Date日期单独做处理

            nkids.setTbrid(currentUser.getId());
            nkRsBmysxmsbService.updateById(nkids);
        }else {
            oaid = GetUuIdUtils.ReplaceUuId();


            nkRsBmysxmsb.setId(oaid);

            nkRsBmysxmsb.setTbrid(currentUser.getId());
            nkRsBmysxmsb.setTbrxm(currentUser.getName());
            nkRsBmysxmsb.setFsqks(currentUser.getOrgName());
            nkRsBmysxmsb.setFsqsj(DateConversionUtils.DateToYMDMM(new Date()));


            nkRsBmysxmsbService.save(nkRsBmysxmsb);
        }

        /**
         * @Author: lhb
         * @Description : 是否发起流程   如果是开始申请就跳转流程
         *               在这里设置  指定下个环节节点 做当前跳转流程的判断，然后设置变量接收环节的值，写到nextNodeName中
         * @DateTime:
         * @Params: Fsffqlc
         */
        String msg = "保存成功";
        String lcmbCode = OaFlowConstant.NK_BM_YSSBLC;

        OaJobEntity job = new OaJobEntity();
        // 初始化流程
        Result result = newNkbmyssbFlowService.createProcess(lcmbCode,oaid, currentUser);
        //做一次规则校验 如果查到此oaid 在表中已经插入 那就执行更新
        NkRsBmysxmsb nkRsBmysxmsb1 = nkRsBmysxmsbService.getById(oaid);
        List<OaProcessBusiness> oaProcessBusinessList = oaProcessBusinessService.list(new LambdaQueryWrapper<OaProcessBusiness>()
                .eq(OaProcessBusiness::getFpid, oaid));
        String bt = currentUser.getName()+"提交的科室预算申报"; //标题
        String zy = "申请日期:["+ nkRsBmysxmsb1.getFsqsj() +"]"+"\n"
                +"申请科室:["+ nkRsBmysxmsb1.getFsqks() +"\n";
        if (oaProcessBusinessList.size() == 0){
            //初始化的时候 像 流程业务主表添加拼接初始化数据
            oaProcessBusinessService.addProcess(oaid,zy,bt,lcmbCode,OaFlowConstant.NK);

        }else {
            String id = oaProcessBusinessList.get(0).getId();  //当前已经插入的主键id 然后更新 摘要信息
            OaProcessBusiness oaProcessBusiness = oaProcessBusinessService.getById(id);
            oaProcessBusiness.setFzy(zy);
            oaProcessBusinessService.updateById(oaProcessBusiness);

        }

        if (!result.isSuccess()){
            return HttpResult.error(result.getMessage());
        }else {
            job = (OaJobEntity) result.getResult();
            if (job != null) {
                // 是否提交流程
                if(StringUtils.isBlank(oaid)){
                    return HttpResult.error("参数丢失");
                }
                String nextNodeId = "";
                String nextNodeDbrId = "";
                if (StringUtils.isNotBlank(nkRsBmysxmsb.getFsffqlc()) && nkRsBmysxmsb.getFsffqlc().equals(OaCommonFlowConstant.SFFQLC_YES)) {
                    //在这里判断一步 判断绩效申报与预算申报 是否匹配
                    newNkbmyssbFlowService.getyssb(nkRsBmysxmsb);


                    if (StringUtils.isBlank(nkRsBmysxmsb.getFlczt())) {
                        nkRsBmysxmsb.setFlczt(OaCommonFlowConstant.FLOW_LCZB);
                    }
                    Result result1 = newNkbmyssbFlowService.passJob(oaid,job.getId(),"同意", nextNodeId, nextNodeDbrId);
                    if (!result1.isSuccess()) {
                        return HttpResult.error(result.getMessage());
                    }
                    msg = "提交成功";
                    //提交完成后 更新通知信息
                    oaSysTzMessageService.tjMessage(oaid);

                    List<OaProcessBusiness> oaProcessBusinessList1 = oaProcessBusinessService.list(new LambdaQueryWrapper<OaProcessBusiness>()
                            .eq(OaProcessBusiness::getFpid, oaid));
                    OaProcessBusiness oaProcessBusiness = oaProcessBusinessList1.get(0);
                    OaProcessBusiness byId1 = oaProcessBusinessService.getById(oaProcessBusiness.getId());
                    byId1.setFsfkch(0);
                    OaJobEntity oaJob = oaSpcySqsxJobService.getById(job);
                    if (oaJob.getFhjmc().equals(OaFlowConstant.CCSP_HJMC_ZXLDSH)) {
                        byId1.setFsfkbx(OaFlowConstant.QXJ_YES);
                    }

                    byId1.setFcshdb(OaFlowConstant.FLOW_BLZT_YB);
                    oaProcessBusinessService.updateById(byId1);
                    myLcFlowService.recall(oaid);
                }
            }
        }

        HashMap map = new HashMap();
        map.put("msg",msg);
        map.put("nkMap",nkRsBmysxmsb);
        map.put("jobMap",job);

        return HttpResult.ok(map);
    }


    /**
     *
     */

    /**
     * 内控-出差审批保存接口
     */
    @AutoLog(value = "内控-部门预算申报保存接口")
    @ApiOperation(value = "内控-部门预算申报保存接口")
    @PostMapping(value = "/saveFlow")
    public HttpResult<?> saveFlow(@RequestBody OaFlowVo oaFlowVo) {
        String submitType = OaCommonFlowConstant.SUBMIT_TYPE_SAVE; // 保存

        String jobId = oaFlowVo.getJobid(); // 当前流程任务id
        String oaid = oaFlowVo.getOaid(); // 当前办公主键id
        String opinion = oaFlowVo.getOpinion(); // 办理意见

        if (StringUtils.isBlank(oaFlowVo.getLcmbCode())){
            oaFlowVo.setLcmbCode(OaFlowConstant.NK_CCSP);
        }
        if (StringUtils.isBlank(jobId)){
            return HttpResult.error("流程任务id参数丢失，请联系管理员");
        }
        // 流程处理
        Result httpResult = newNkbmyssbFlowService.handleFlow(oaFlowVo, null, jobId, oaid, submitType, opinion);
        if (!httpResult.isSuccess()){
            return HttpResult.error(httpResult.getMessage());
        }
        Map map = new HashMap();
        HttpResult<Object> res = new HttpResult<>(true);
        res.setMessage("保存成功");
        res.setResult(map);
        return res;
    }


    @AutoLog(value = "内控-部门预算申报提交接口")
    @ApiOperation(value = "内控-部门预算申报提交接口")
    @PostMapping(value = "/submitFlow")
    public HttpResult<?> submitFlow(@RequestBody OaFlowVo oaFlowVo) {

        String submitType = OaCommonFlowConstant.SUBMIT_TYPE_SUBMIT; // 提交
        CurrentUserVo currentUser = ThreadContextHelper.getCurrentUser();
        String jobId = oaFlowVo.getJobid();




        String oaid = oaFlowVo.getOaid();
        String opinion = oaFlowVo.getOpinion();
        NkRsBmysxmsb oaId = nkRsBmysxmsbService.getById(oaid);
        OaJobEntity job = oaSpcySqsxJobService.getById(jobId);

        if (job.getFdbrid() != null && !job.getFdbrid().isEmpty()) {
            // 检查id是否在逗号分隔的字符串中
            boolean contains = job.getFdbrid().contains(currentUser.getId());
            if (!contains){
                throw new BusinessException("您没有权限提交该流程");
            }
        }



        if (StringUtils.isBlank(oaFlowVo.getLcmbCode())){
            oaFlowVo.setLcmbCode(OaFlowConstant.NK_BM_YSSBLC);
        }

        if (job.getFhjmc().equals(OaFlowConstant.YSSBLC_BM_SQ)){
            //重新获取摘要信息
            NkRsBmysxmsb nkRsBmysxmsb = nkRsBmysxmsbService.getById(oaid);
            List<OaProcessBusiness> oaProcessBusinessList = oaProcessBusinessService.list(new LambdaQueryWrapper<OaProcessBusiness>()
                    .eq(OaProcessBusiness::getFpid, oaid));
            String bt = currentUser.getName()+"提交的部门预算申报"; //标题
            String zy = "申请日期:["+ nkRsBmysxmsb.getFsqsj() +"]"+"\n"
                    +"申请科室:["+ nkRsBmysxmsb.getFsqks() + "\n";
            if (oaProcessBusinessList.size() == 0){
                //初始化的时候 像 流程业务主表添加拼接初始化数据
                oaProcessBusinessService.addProcess(oaid,zy,bt,"NK_BM_YSSBLC",OaFlowConstant.NK);

            }else {
                String id = oaProcessBusinessList.get(0).getId();  //当前已经插入的主键id 然后更新 摘要信息
                OaProcessBusiness oaProcessBusiness = oaProcessBusinessService.getById(id);
                oaProcessBusiness.setFzy(zy);
                oaProcessBusinessService.updateById(oaProcessBusiness);

            }

        }else if (job.getFhjmc().equals(OaFlowConstant.YSSBLC_BM_FGLDSH)) {

        } else {
            oaId.setFlczt(OaCommonFlowConstant.FLOW_LCZB);
        }
        if (StringUtils.isBlank(oaId.getFsffqlc())) {
            oaId.setFsffqlc(OaCommonFlowConstant.SFFQLC_YES);
        }

        nkRsBmysxmsbService.updateById(oaId);

        if (StringUtils.isBlank(jobId)) {
            return HttpResult.error("流程任务id参数丢失，请联系管理员");
        }
        /* if (StringUtils.isBlank(opinion)){
            return HttpResult.error("请填写办理意见");2
        }*/

        OaJobEntity nowJob = null;
        Result httpResult1 = newNkbmyssbFlowService.handleFlow(oaFlowVo, nowJob, jobId, oaid, submitType, opinion);
        if (!httpResult1.isSuccess()){
            return HttpResult.error(httpResult1.getMessage());
        }
        List<OaProcessBusiness> oaProcessBusinessList1 = oaProcessBusinessService.list(new LambdaQueryWrapper<OaProcessBusiness>()
                .eq(OaProcessBusiness::getFpid, oaid));
        OaProcessBusiness oaProcessBusiness = oaProcessBusinessList1.get(0);
        OaProcessBusiness byId1 = oaProcessBusinessService.getById(oaProcessBusiness.getId());
        byId1.setFsfkch(0);

        if (job.getFhjmc().equals(OaFlowConstant.YSSBLC_BM_FGLDSH)) {
            byId1.setFsfkbx(OaFlowConstant.QXJ_YES);
        }

        byId1.setFcshdb(OaFlowConstant.FLOW_BLZT_YB);
        oaProcessBusinessService.updateById(byId1);

        //提交完成后 更新待办信息
        oaSysTzMessageService.tjMessage(oaid);
        myLcFlowService.recall(oaid);


        return HttpResult.ok("提交成功");
    }





    /**
     * 批量查询
     */
    @AutoLog(value = "批量查询")
    @ApiOperation(value = "批量查询")
    @ApiImplicitParam(value = "jobids", name = "jobids", required = true)
    @GetMapping(value = "queryBatchJobByJobIds")
    public HttpResult<?> queryBatchJobByJobIds(@RequestParam("jobids")String jobids) {
        if (StringUtils.isBlank(jobids)) {
            return HttpResult.error("参数不能为空,请选择数据");
        }
        List<Map> mapList = new ArrayList<>();
        List<String> jobidsList = Arrays.asList(jobids.split(","));
        if (CollectionUtils.isNotEmpty(jobidsList)) {
            for (String jobid : jobidsList){
                mapList.add(newNkbmyssbFlowService.getJobConcernByJobId(jobid));
            }
        }
        return HttpResult.ok(mapList);
    }

    /**
     * 查询当前流程任务详情-通过当前流程任务id
     */
    @AutoLog(value = "查询当前流程任务详情-通过当前流程任务id")
    @ApiOperation(value = "查询当前流程任务详情-通过当前流程任务id")
    @ApiImplicitParam(value = "jobid", name = "流程任务id", required = true)
    @GetMapping(value = "queryJobByJobId")
    public HttpResult<?> queryJobByJobId(@RequestParam("jobid") String jobid) {
        if (StringUtils.isBlank(jobid)) {
            return HttpResult.error("流程任务id不能为空");
        }
        Map map = newNkbmyssbFlowService.getJobConcernByJobId(jobid);
        return HttpResult.ok(map);
    }

    /**
     * 获取已办列表-通过当前流程id-自定义退回
     *
     * @param jobid
     * @return
     */
    @AutoLog(value = "获取已办列表-通过当前流程id-自定义退回")
    @ApiOperation(value = "获取已办列表-通过当前流程id-自定义退回")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "jobid", value = "流程任务id"),
            @ApiImplicitParam(name = "isZdhj", value = "是否指定环节，默认：true，指定")
    })
    @GetMapping(value = "queryAllYbJob")
    public HttpResult<?> queryAllYbJob(@RequestParam(value = "jobid", defaultValue = "") String jobid,
                                       @RequestParam(value = "isZdhj", defaultValue = "true") boolean isZdhj) {
        List<Map<String, String>> currentJobPrevious = newNkbmyssbFlowService.getCurrentJobPrevious(jobid, isZdhj);
        return HttpResult.ok(currentJobPrevious);
    }

    /**
     * 退回环节
     *
     * @return
     */
    @AutoLog(value = "自定义-退回环节")
    @ApiOperation(value = "自定义-退回环节")
    @PostMapping(value = "returnUpperzdyFlowJob")
    public HttpResult<?> returnUpperzdyFlowJob(@RequestBody OaReturnVo oaReturnVo) {
        newNkbmyssbFlowService.returnZdJob(oaReturnVo);

        //退回更新通知信息
        OaJobEntity oaJob = oaSpcySqsxJobService.getById(oaReturnVo.getJobid());
        String fpid = oaJob.getFpid();
        oaSysTzMessageService.endMessage(fpid,false,false,true);

        return HttpResult.ok("退回成功");
    }

    @AutoLog(value = "删除部门预算申报")
    @ApiOperation(value = "删除部门预算申报")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "jobids",value = "流程任务id,逗号分割",required = true)
    })
    @DeleteMapping(value = "deleteLgqsFlowJob")
    public HttpResult<?> deleteLgqsFlowJob(@RequestParam(value = "jobids") String jobids){
        if (StringUtils.isBlank(jobids)){
            return HttpResult.error("参数不能为空");
        }
        List<String> jobIdList = Arrays.asList(jobids.split(","));
        String logNr = "";
        Map<String, Object> map = new HashMap<>();
        if (CollectionUtils.isNotEmpty(jobIdList)){
            List<OaJobEntity> jobList = oaSpcySqsxJobService.listByIds(jobIdList);
            if (CollectionUtils.isNotEmpty(jobList)){
                for (OaJobEntity job : jobList) {
                    oaSpcySqsxJobService.removeById(job.getId());
                    NkRsBmysxmsb nkRsYstpsq = nkRsBmysxmsbService.getById(job.getFpid());
                    if (nkRsYstpsq != null) {
                        nkRsBmysxmsbService.removeById(job.getFpid());

                        logNr = "删除部门预算申报" + job.getFhjmc() + ": ";
                        map = ObjectToMapUtils.objectToMap(nkRsYstpsq);
                        logNr += LogUtils.MapToStringMethod(map);

                        spcyLogService.addLogs(job.getFhjmc(), logNr, job.getFpid(), OaFlowConstant.NK_BM_YSSBLC, OaCommonFlowConstant.LOGS_SYS_TYPE_SC);
                    }
                }
            }
        }

        return HttpResult.ok("删除成功");
    }




    /**
     * 新增项目依据
     */
    @AutoLog(value = "新增项目依据")
    @ApiOperation(value = "新增项目依据")
    @GetMapping(value = "addXmyj")
    public HttpResult addXmyj(String bmyssbid){
        NkBmysxmsbXmyj nkBmysxmsbXmyj = new NkBmysxmsbXmyj();
        nkBmysxmsbXmyj.setId(GetUuIdUtils.ReplaceUuId());
        nkBmysxmsbXmyj.setFbmysxmsbid(bmyssbid);

        nkRsBmysxmsbXmyjService.save(nkBmysxmsbXmyj);
        return HttpResult.ok("成功");

    }


    /**
     * 新增项目依据
     */
    @AutoLog(value = "编辑项目依据")
    @ApiOperation(value = "编辑项目依据")
    @PutMapping(value = "editXmyj")
    public HttpResult editXmyj(@RequestBody NkBmysxmsbXmyj nkBmysxmsbXmyj){
        nkRsBmysxmsbXmyjService.updateById(nkBmysxmsbXmyj);
        return HttpResult.ok("成功");

    }

    /**
     * 删除项目依据
     */
    @AutoLog(value = "删除项目依据")
    @ApiOperation(value = "删除项目依据")
    @GetMapping(value = "deXmyj")
    public HttpResult deXmyj(String id){

        nkRsBmysxmsbXmyjService.removeById(id);
        return HttpResult.ok("成功");

    }

    /**
     * 新增项目内容
     */
    @AutoLog(value = "新增项目内容")
    @ApiOperation(value = "新增项目内容")
    @GetMapping(value = "addXmnr")
    public HttpResult addXmnr(String bmyssbid, String lx, String lxs){
        CurrentUserVo currentUser = ThreadContextHelper.getCurrentUser();
        NkBmysxmsbXmnr nkRsBmysxmsbXmnr = new NkBmysxmsbXmnr();
        nkRsBmysxmsbXmnr.setId(GetUuIdUtils.ReplaceUuId());
        nkRsBmysxmsbXmnr.setFbmysxmsbid(bmyssbid);
        nkRsBmysxmsbXmnr.setLx(lx);
        nkRsBmysxmsbXmnr.setLxs(lxs);
        nkRsBmysxmsbXmnr.setFktfzks(currentUser.getOrgName());

        //初始化费用标准
        /*nkRsBmysxmsbXmnr.setClfbzbz("180"); //差旅费补助标准
        nkRsBmysxmsbXmnr.setZxfbzbz("330"); //住宿费补助标准
        nkRsBmysxmsbXmnr.setJtfbzbz("200"); //交通费补助标准
        nkRsBmysxmsbXmnr.setLwfbzbz("300"); //劳务费补助标准*/

        nkbxmsbXmnrService.save(nkRsBmysxmsbXmnr);
        return HttpResult.ok("成功");

    }

    /**
     * 新增项目内容
     */
    @AutoLog(value = "PostMapping新增项目内容")
    @ApiOperation(value = "PostMapping新增项目内容")
    @PostMapping(value = "addXmnrs")
    public HttpResult addXmnrs(@RequestBody NkBmysxmsbXmnr nkbxmsbXmnr){

        nkbxmsbXmnrService.save(nkbxmsbXmnr);
        return HttpResult.ok("成功");

    }

    /**
     * 编辑项目内容
     */
    @AutoLog(value = "编辑项目内容")
    @ApiOperation(value = "编辑项目内容")
    @PutMapping(value = "/editXmnr")
    public HttpResult<?> editXmnr(@RequestBody NkBmysxmsbXmnr nkbxmsbXmnr) {
        newNkbmyssbFlowService.editXmnr(nkbxmsbXmnr);
        return HttpResult.ok("成功");
    }

    /**
     * 删除项目内容
     *
     */
    @AutoLog(value = "删除项目内容")
    @ApiOperation(value = "删除项目内容")
    @GetMapping(value = "deXmnr")
    public HttpResult deXmnr(String id){

        nkbxmsbXmnrService.removeById(id);
        return HttpResult.ok("成功");

    }

    /**
     * 查看项目依据列表
     */
    @AutoLog(value = "查看项目依据")
    @ApiOperation(value = "查看项目依据")
    @GetMapping(value = "getXmyjList")
    public HttpResult getXmyjList(String bmyssbid){


        List<NkBmysxmsbXmyj> bmysxmsbXmyjList = nkRsBmysxmsbXmyjService.list(new LambdaQueryWrapper<NkBmysxmsbXmyj>()
                .eq(NkBmysxmsbXmyj::getFbmysxmsbid, bmyssbid)
                .orderByAsc(NkBmysxmsbXmyj::getCreateTime));

        return HttpResult.ok(bmysxmsbXmyjList);

    }


    /**
     * 查看项目内容列表
     */
    @AutoLog(value = "查看项目内容列表")
    @ApiOperation(value = "查看项目内容列表")
    @GetMapping(value = "getXmnrList")
    public HttpResult getXmnrList(String bmyssbid){


        List<NkBmysxmsbXmnr> bmysxmsbXmnrList = nkbxmsbXmnrService.list(new LambdaQueryWrapper<NkBmysxmsbXmnr>()
                .eq(NkBmysxmsbXmnr::getFbmysxmsbid, bmyssbid)
                .orderByAsc(NkBmysxmsbXmnr::getCreateTime));

        return HttpResult.ok(bmysxmsbXmnrList);

    }

    /**
     * 保存本表
     */
    @AutoLog(value = "内控-部门预算申报-编辑")
    @ApiOperation(value = "内控-部门预算申报-编辑")
    @PutMapping(value = "/edit")
    public HttpResult<?> edit(@RequestBody NkRsBmysxmsb nkRsBmysxmsb) {
        nkRsBmysxmsbService.updateById(nkRsBmysxmsb);

        //更新之后在进行一次计算
        //如果传入的每个 第一季度 第二季度 第三季度 第四季度 的数据不为空，那就 更新到对应的费用里面
        NkRsBmysxmsb bmysxmsb = nkRsBmysxmsbService.getById(nkRsBmysxmsb.getId());
        //差旅费一季度 二季度 三季度 四季度 支出计划
        BigDecimal dyjdclf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhyjdclf()).orElseGet(() -> "0"));
        BigDecimal dejdclf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhejdclf()).orElseGet(() -> "0"));
        BigDecimal dsjdclf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhsjdclf()).orElseGet(() -> "0"));
        BigDecimal dsijdclf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhsijdclf()).orElseGet(() -> "0"));

        String fzcxmflclf =String.valueOf(dyjdclf.add(dejdclf).add(dsjdclf).add(dsijdclf));
        bmysxmsb.setFzcxmflclf(fzcxmflclf);

        //劳务费
        BigDecimal dyjdlwf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhyjdlwf()).orElseGet(() -> "0"));
        BigDecimal dejdlwf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhejdlwf()).orElseGet(() -> "0"));
        BigDecimal dsjdlwf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhsjdlwf()).orElseGet(() -> "0"));
        BigDecimal dsijdlwf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhsijdlwf()).orElseGet(() -> "0"));

        String fzcxmflwf =String.valueOf(dyjdlwf.add(dejdlwf).add(dsjdlwf).add(dsijdlwf));
        bmysxmsb.setFzcxmfllwf(fzcxmflwf);

        //印刷费
        BigDecimal dyjdyxf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhyjdysf()).orElseGet(() -> "0"));
        BigDecimal dejdyxf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhejdysf()).orElseGet(() -> "0"));
        BigDecimal dsjdyxf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhsjdysf()).orElseGet(() -> "0"));
        BigDecimal dsijdyxf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhsijdysf()).orElseGet(() -> "0"));

        String fzcxmfysf =String.valueOf(dyjdyxf.add(dejdyxf).add(dsjdyxf).add(dsijdyxf));
        bmysxmsb.setFzcxmflysf(fzcxmfysf);


        //培训费
        BigDecimal dyjdpxf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhyjdpxf()).orElseGet(() -> "0"));
        BigDecimal dejdpxf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhejdpxf()).orElseGet(() -> "0"));
        BigDecimal dsjdpxf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhsjdpxf()).orElseGet(() -> "0"));
        BigDecimal dsijdpxf = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhsijdpxf()).orElseGet(() -> "0"));

        String fzcxmfpxf =String.valueOf(dyjdpxf.add(dejdpxf).add(dsjdpxf).add(dsijdpxf));
        bmysxmsb.setFzcxmflpxf(fzcxmfpxf);


        //其他
        BigDecimal dyjdqt = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhyjdzcje()).orElseGet(() -> "0"));
        BigDecimal dejdqt = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhejdzcje()).orElseGet(() -> "0"));
        BigDecimal dsjddqt = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhsjdzcje()).orElseGet(() -> "0"));
        BigDecimal dsijddqt = new BigDecimal(Optional.ofNullable(bmysxmsb.getZjzcjhsijdzcje()).orElseGet(() -> "0"));


        String fzcxmfqt = String.valueOf(dyjdqt.add(dejdqt).add(dsjddqt).add(dsijddqt));
        bmysxmsb.setFzcxmflqt(fzcxmfqt);

        BigDecimal ktjf = new BigDecimal(Optional.ofNullable(bmysxmsb.getFzcxmflktjf()).orElseGet(() -> "0"));

        //合计
       String xmje  =String.valueOf(dyjdclf.add(dejdclf).add(dsjdclf).add(dsijdclf)
                                    .add(dyjdlwf.add(dejdlwf).add(dsjdlwf).add(dsijdlwf)
                                    .add(dyjdyxf.add(dejdyxf).add(dsjdyxf).add(dsijdyxf)
                                    .add(dyjdpxf.add(dejdpxf).add(dsjdpxf).add(dsijdpxf)
                                    .add(dyjdqt.add(dejdqt).add(dsjddqt).add(dsijddqt).add(ktjf))))));

        bmysxmsb.setXmje(xmje);

        nkRsBmysxmsbService.updateById(bmysxmsb);
        NkRsBmysxmsb bmysxmsbs = nkRsBmysxmsbService.getById(bmysxmsb.getId());

        return HttpResult.ok(bmysxmsbs);
    }


    /**
     * 新增部门预算申报
     */
    @AutoLog(value = "新增部门预算申报")
    @ApiOperation(value = "新增部门预算申报")
    @GetMapping(value = "/addbmyssb")
    public HttpResult<?> addbmyssb() {
        //当前登陆人信息
        CurrentUserVo currentUser = ThreadContextHelper.getCurrentUser();

        //新增为下一年的年份
        LocalDate currentDate = LocalDate.now().plusYears(1);
        //当前年份
//        String year = DateConversionUtils.DateToYear(new Date());
        String year = String.valueOf(currentDate.getYear());


        //获取当前部门
        String orgName = currentUser.getOrgName();
        List<NkRsBmysxmsb> rsBmysxmsbs = nkRsBmysxmsbService.list(new LambdaQueryWrapper<NkRsBmysxmsb>()
                .eq(NkRsBmysxmsb::getFsqks, orgName)
                .eq(NkRsBmysxmsb::getFnd, year));

        if (CollectionUtils.isEmpty(rsBmysxmsbs)){
            NkRsBmysxmsb nkRsBmysxmsb = new NkRsBmysxmsb();
            nkRsBmysxmsb.setId(GetUuIdUtils.ReplaceUuId());
            nkRsBmysxmsb.setFsqks(orgName);
            nkRsBmysxmsb.setFsqsj(DateConversionUtils.DateToStringYYYYMMDD(new Date()));
            nkRsBmysxmsb.setFnd(year);

            List<NkBmysxmsbsplc> nkBmysxmsbsplcs = nkBmysxmsbsplcService.list(new LambdaQueryWrapper<NkBmysxmsbsplc>()
                    .eq(NkBmysxmsbsplc::getFnd, year));
            if (CollectionUtils.isNotEmpty(nkBmysxmsbsplcs)){
                nkRsBmysxmsb.setFjhid(nkBmysxmsbsplcs.get(0).getId());
            }else {
                NkBmysxmsbsplc nkBmysxmsbsplc = new NkBmysxmsbsplc();
                String id = GetUuIdUtils.ReplaceUuId();
                nkBmysxmsbsplc.setId(id);
                nkBmysxmsbsplc.setFnd(year);
                nkBmysxmsbsplcService.save(nkBmysxmsbsplc);
                nkRsBmysxmsb.setFjhid(id);
            }
            nkRsBmysxmsbService.save(nkRsBmysxmsb);
        }else {
            return HttpResult.error("该部门已经新增过部门预算申报");
        }

        return HttpResult.ok("新增成功");
    }


    @AutoLog(value = "查看本部门的预算申报")
    @ApiOperation(value = "查看本部门的预算申报")
    @GetMapping(value = "/listbmyssb")
    public HttpResult<?> listbmyssb(NkRsBmysxmsb nkRsBmysxmsb ,@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        //当前登陆人信息
        CurrentUserVo currentUser = ThreadContextHelper.getCurrentUser();
        //当前年份


        //因为新增为下一年，所以查询为内控全局的年度的下一年
        List<NkRsnd> rsnds = nkRsNdService.list(new LambdaQueryWrapper<NkRsnd>()
                .eq(NkRsnd::getFsfxz, OaCommonFlowConstant.NDXZ_YES));
        String fnd1 = rsnds.get(0).getFnd();
        int ndi = Integer.valueOf(fnd1) + 1;


        //获取当前部门
        String orgName = currentUser.getOrgName();

        LambdaQueryWrapper<NkRsBmysxmsb> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(NkRsBmysxmsb::getFsqks, orgName);
        queryWrapper.eq(StringUtils.isNotBlank(nkRsBmysxmsb.getFnd()),NkRsBmysxmsb::getFnd,nkRsBmysxmsb.getFnd());
        queryWrapper.eq(NkRsBmysxmsb :: getFnd,String.valueOf(ndi));


        List<NkRsnd> nkRsnds = nkRsNdService.list(new LambdaQueryWrapper<NkRsnd>()
                .eq(NkRsnd::getFsfxz, OaCommonFlowConstant.NDXZ_YES));
        if (CollectionUtils.isNotEmpty(nkRsnds)){
            String fnd = nkRsnds.get(0).getFnd();
            int fndx = Integer.valueOf(fnd) + 1;
            queryWrapper.eq(NkRsBmysxmsb :: getFnd,String.valueOf(fndx));
        }


        Page<NkRsBmysxmsb> page = new Page<>(pageNo, pageSize);
            IPage<NkRsBmysxmsb> pageList = nkRsBmysxmsbService.page(page,queryWrapper);

            return HttpResult.ok(pageList);


    }


    /**
     * 新增预算申报绩效，同时新增预算申报绩效-绩效指标
     */
    @AutoLog(value = "新增预算申报绩效")
    @ApiOperation(value = "新增预算申报绩效")
    @PostMapping(value = "/addjxsb")
    public HttpResult<?> addjxsb(@RequestBody NkYssbjxb nkYssbjxb){
        CurrentUserVo currentUser = ThreadContextHelper.getCurrentUser();
        if (StringUtils.isBlank(nkYssbjxb.getFbmyssbid())){
            return HttpResult.error("部门预算申报id为空");
        }
        if (StringUtils.isBlank(nkYssbjxb.getFjhid())){
            return HttpResult.error("预算申报计划id为空");
        }
        nkYssbjxb.setFsbks(currentUser.getOrgName());
        LocalDate localDate = LocalDate.now().plusYears(1);

        List<NkRsBmysxmsb> rsBmysxmsbs = nkRsBmysxmsbService.list(new LambdaQueryWrapper<NkRsBmysxmsb>()
                .eq(NkRsBmysxmsb::getId, nkYssbjxb.getFbmyssbid()));
        
        if (nkYssbjxb.getFlx().equals(OaCommonFlowConstant.JXZBLX_LWF)){
            nkYssbjxb.setFzjzeje(rsBmysxmsbs.get(0).getFzcxmfllwf());
        } else if (nkYssbjxb.getFlx().equals(OaCommonFlowConstant.JXZBLX_CLF)) {
            nkYssbjxb.setFzjzeje(rsBmysxmsbs.get(0).getFzcxmflclf());
        } else if (nkYssbjxb.getFlx().equals(OaCommonFlowConstant.JXZBLX_PXF)) {
            nkYssbjxb.setFzjzeje(rsBmysxmsbs.get(0).getFzcxmflpxf());
        } else if (nkYssbjxb.getFlx().equals(OaCommonFlowConstant.JXZBLX_YSF)) {
            nkYssbjxb.setFzjzeje(rsBmysxmsbs.get(0).getFzcxmflysf());
        } else if (nkYssbjxb.getFlx().equals(OaCommonFlowConstant.JXZBLX_KTF)) {
            nkYssbjxb.setFzjzeje(rsBmysxmsbs.get(0).getFzcxmflktjf());
        }
        //按照当前的年份加1
        nkYssbjxb.setFnd(String.valueOf(localDate.getYear()));
        nkYssbjxbService.save(nkYssbjxb);
        return HttpResult.ok("新增成功");

    }



    @AutoLog(value = "编辑预算申报绩效")
    @ApiOperation(value = "编辑预算申报绩效")
    @PutMapping(value = "/editjxsb")
    public HttpResult<?> editjxsb(@RequestBody NkYssbjxb nkYssbjxb){

        nkYssbjxb.setFxmssdw(OaCommonFlowConstant.YSSB_XMSSDW);
        nkYssbjxb.setFxmzgdw(OaCommonFlowConstant.YSSB_XMZGDW);
        nkYssbjxb.setFxmsx(OaCommonFlowConstant.YSSB_XMSX);
        nkYssbjxb.setFzjzezjly(OaCommonFlowConstant.YSSB_ZJLY);
        nkYssbjxbService.updateById(nkYssbjxb);
        return HttpResult.ok("编辑成功");

    }

    /**
     * 查询预算申报绩效表
     */
    @AutoLog(value = "查看预算申报绩效")
    @ApiOperation(value = "查看预算申报绩效")
    @GetMapping(value = "/listjxsb")
    public HttpResult<?> listjxsb(NkYssbjxb nkYssbjxb ,@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        LambdaQueryWrapper<NkYssbjxb> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(nkYssbjxb.getFbmyssbid()),NkYssbjxb::getFbmyssbid,nkYssbjxb.getFbmyssbid());
        queryWrapper.eq(StringUtils.isNotBlank(nkYssbjxb.getFjhid()),NkYssbjxb::getFjhid,nkYssbjxb.getFjhid());


        List<NkRsnd> nkRsnds = nkRsNdService.list(new LambdaQueryWrapper<NkRsnd>()
                .eq(NkRsnd::getFsfxz, OaCommonFlowConstant.NDXZ_YES));
        if (CollectionUtils.isNotEmpty(nkRsnds)){
            String fnd = nkRsnds.get(0).getFnd();
            int fndx = Integer.valueOf(fnd) + 1;
            queryWrapper.eq(NkYssbjxb::getFnd,String.valueOf(fndx));
        }

//        queryWrapper.eq(NkYssbjxb::getFnd,nkRsnds.get(0).getFnd());
        queryWrapper.orderByAsc(NkYssbjxb :: getCreateTime);
        Page<NkYssbjxb> page = new Page<>(pageNo, pageSize);
        IPage<NkYssbjxb> pageList = nkYssbjxbService.page(page,queryWrapper);
        return HttpResult.ok(pageList);

    }

    /**
     * 删除预算申报绩效
     */
    @AutoLog(value = "删除预算申报绩效")
    @ApiOperation(value = "删除预算申报绩效")
    @DeleteMapping(value = "/deletejxsb")
    public HttpResult<?> deletejxsb(String id){

        nkYssbjxbService.removeById(id);
        return HttpResult.ok("删除成功");

    }

    /**
     * 新增预算申报绩效-绩效指标
     */
    @AutoLog(value = "新增预算申报绩效-绩效指标")
    @ApiOperation(value = "新增预算申报绩效-绩效指标")
    @PostMapping(value = "/addjxzb")
    public HttpResult<?> addjxzb(@RequestBody NkYssbjxbjxzb nkYssbjxbjxzb){

        if (StringUtils.isBlank(nkYssbjxbjxzb.getFyssbxjid())){
            return HttpResult.error("预算申报绩效id为空");
        }
        if (StringUtils.isBlank(nkYssbjxbjxzb.getFjhid())){
            return HttpResult.error("预算申报计划id为空");
        }
        if (StringUtils.isBlank(nkYssbjxbjxzb.getFlx())){
            return HttpResult.error("类型为空");
        }

//        nkYssbjxbService.getById(nkYssbjxbjxzb.getFyssbxjid());
        List<NkYssbjxbjxzb> nkYssbjxbjxzbs = nkYssbjxbjxzbService.list(new LambdaQueryWrapper<NkYssbjxbjxzb>()
                .eq(NkYssbjxbjxzb::getFyssbxjid, nkYssbjxbjxzb.getFyssbxjid())
                .eq(NkYssbjxbjxzb::getFejzblx, nkYssbjxbjxzb.getFejzblx()));
        if (CollectionUtils.isNotEmpty(nkYssbjxbjxzbs)){
            return HttpResult.error("该类型已存在");
        }

        nkYssbjxbjxzb.setFks(ThreadContextHelper.getCurrentUser().getDeptName());
        LocalDate localDate = LocalDate.now().plusYears(1);


        nkYssbjxbjxzb.setFnd(String.valueOf(localDate.getYear()));
        nkYssbjxbjxzbService.save(nkYssbjxbjxzb);
        return HttpResult.ok("新增成功");

    }



    @AutoLog(value = "编辑预算申报绩效-绩效指标")
    @ApiOperation(value = "编辑预算申报绩效-绩效指标")
    @PutMapping(value = "/editjxzb")
    public HttpResult<?> editjxzb(@RequestBody NkYssbjxbjxzb nkYssbjxbjxzb){


        nkYssbjxbjxzbService.updateById(nkYssbjxbjxzb);
        return HttpResult.ok("编辑成功");

    }

    /**
     * 查询预算申报绩效-绩效指标
     */
    @AutoLog(value = "查看预算申报绩效-绩效指标")
    @ApiOperation(value = "查看预算申报绩效-绩效指标")
    @GetMapping(value = "/listjxzb")
    public HttpResult<?> listjxzb(NkYssbjxbjxzb nkYssbjxbjxzb ,@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        LambdaQueryWrapper<NkYssbjxbjxzb> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(nkYssbjxbjxzb.getFyssbxjid()),NkYssbjxbjxzb::getFyssbxjid,nkYssbjxbjxzb.getFyssbxjid());
        queryWrapper.eq(StringUtils.isNotBlank(nkYssbjxbjxzb.getFjhid()),NkYssbjxbjxzb::getFjhid,nkYssbjxbjxzb.getFjhid());
        queryWrapper.eq(StringUtils.isNotBlank(nkYssbjxbjxzb.getFlx()),NkYssbjxbjxzb::getFlx,nkYssbjxbjxzb.getFlx());

        List<NkRsnd> nkRsnds = nkRsNdService.list(new LambdaQueryWrapper<NkRsnd>().eq(NkRsnd::getFsfxz, OaCommonFlowConstant.NDXZ_YES));
        if (CollectionUtils.isNotEmpty(nkRsnds)){
            String fnd = nkRsnds.get(0).getFnd();
            int fndx = Integer.valueOf(fnd) + 1;
            queryWrapper.eq(NkYssbjxbjxzb::getFnd,String.valueOf(fndx));
        }

//        queryWrapper.eq(StringUtils.isNotBlank(nkYssbjxbjxzb.getFnd()),NkYssbjxbjxzb::getFnd,nkYssbjxbjxzb.getFnd());

        queryWrapper.orderByAsc(NkYssbjxbjxzb :: getCreateTime);
        Page<NkYssbjxbjxzb> page = new Page<>(pageNo, pageSize);
        IPage<NkYssbjxbjxzb> pageList = nkYssbjxbjxzbService.page(page,queryWrapper);
        return HttpResult.ok(pageList);

    }

    /**
     * 删除预算申报绩效-绩效指标
     */
    @AutoLog(value = "删除预算申报绩效-绩效指标")
    @ApiOperation(value = "删除预算申报绩效-绩效指标")
    @DeleteMapping(value = "/deletejxzb")
    public HttpResult<?> deletejxzb(String id){

        nkYssbjxbjxzbService.removeById(id);
        return HttpResult.ok("删除成功");

    }


//    /**
//     * 汇总预算申报绩效-绩效指标
//     */
//    @AutoLog(value = "汇总预算申报绩效-绩效指标")
//    @ApiOperation(value = "汇总预算申报绩效-绩效指标")
//    @GetMapping(value = "/hzjxzb")
//    public HttpResult<?> hzjxzb(NkYssbjxbjxzb nkYssbjxbjxzb ,@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
//                                  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
//
//
//    }





}

